package com.androidproject;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.androidproject.modele.Article;

public class LineAdapterNews extends BaseAdapter {

	private LayoutInflater lInflater;
	private List<Article> listArticle;
	
	public LineAdapterNews(Context context, List<Article> articles) {
		lInflater = LayoutInflater.from(context);
		this.listArticle = articles;
	}
	
	@Override
	public int getCount() {
		return listArticle.size();
	}

	@Override
	public Object getItem(int position) {
		return listArticle.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View ligne = lInflater.inflate(R.layout.activity_news, parent, false);

		((TextView) ligne.findViewById(R.id.tvDate)).setText(listArticle.get(position).getDate());
		((TextView) ligne.findViewById(R.id.tvTitre)).setText(listArticle.get(position).getTitle());
		((TextView) ligne.findViewById(R.id.tvDescription)).setText(listArticle.get(position).getDescription());
		
		return ligne;
	}

}
